home *** CD-ROM | disk | FTP | other *** search
- class classes.enemy.BatD
- {
- var x;
- var y;
- var moveScript;
- var id;
- var clip;
- var colorR;
- var trans;
- var colorTrans;
- var f2;
- var dir;
- var axis;
- var xDest;
- var yDest;
- var oldDir;
- var xMov = 0;
- var yMov = 0;
- var xMovT = 0;
- var yMovT = 0;
- var speedOrig = 8;
- var speed = 8;
- var xDestMet = false;
- var yDestMet = false;
- var c = 0;
- var life = 2;
- var nudging = false;
- var nc = 0;
- var xA = 0;
- var yA = 0;
- var power = 20;
- var Name = "batD";
- function BatD(px, py, pmoveScript, pid)
- {
- this.x = px;
- this.y = py;
- this.moveScript = pmoveScript.slice();
- this.id = pid;
- _root.d = _root.d + 1;
- this.clip = _root.attachMovie("batB","batD" + this.id + "Clip",_root.d + 50000);
- this.clip._x = this.x;
- this.clip._y = this.y;
- this.colorR = -255;
- this.trans = new flash.geom.Transform(this.clip);
- this.colorTrans = new flash.geom.ColorTransform(0,0,0,1,this.colorR,this.colorR,this.colorR,0);
- this.trans.colorTransform = this.colorTrans;
- this.speed *= _root.dif.speed;
- this.speedOrig = this.speed;
- this.life *= _root.dif.life;
- this.speedVar();
- this.parseMoveScript();
- _root.stats.created = _root.stats.created + 1;
- }
- function bombed(num)
- {
- this.f2 = "death";
- }
- function nudge(pxA, pyA, pscale)
- {
- this.nc = 0;
- this.nudging = true;
- var _loc2_ = pscale / 100;
- this.xA = pxA * _loc2_;
- this.yA = pyA * _loc2_;
- }
- function speedVar()
- {
- if(random(3) == 1)
- {
- this.speed *= _root.randRange2(0.9999,1.0001);
- }
- }
- function twist()
- {
- this.clip.body.gotoAndPlay("twist");
- }
- function parseMoveScript()
- {
- this.dir = this.moveScript[0];
- if(this.dir == "break")
- {
- delete this.moveScript;
- this[this.axis + "MovT"] = 0;
- this.f2 = "wander";
- this.axis = random(10) <= 4 ? "y" : "x";
- this[this.axis + "MovT"] = random(2) <= 0 ? -1 * this.speed : this.speed;
- this.speedVar();
- this.getDirString();
- }
- else
- {
- this[this.axis + "MovT"] = 0;
- this.f2 = "gotoXYDest";
- this.axis = !(this.dir == "L" || this.dir == "R") ? "y" : "x";
- this[this.axis + "MovT"] = !(this.dir == "L" || this.dir == "U") ? this.speed : -1 * this.speed;
- this.speedVar();
- if(this.dir == "L" || this.dir == "U")
- {
- this[this.axis + "Dest"] = this[this.axis] - this.moveScript[1];
- }
- else
- {
- this[this.axis + "Dest"] = this[this.axis] + this.moveScript[1];
- }
- this.moveScript.splice(0,2);
- }
- }
- function gotoXYDest()
- {
- if(Math.abs(this[this.axis + "Dest"] - this[this.axis]) < this.speed + 1)
- {
- if(this.axis == "x")
- {
- this.x = this.xDest;
- }
- else
- {
- this.y = this.yDest;
- }
- this.parseMoveScript();
- }
- }
- function getDirString()
- {
- if(this.xMovT < -1)
- {
- this.dir = "L";
- }
- else if(this.xMovT > 1)
- {
- this.dir = "R";
- }
- else if(this.yMovT > 1)
- {
- this.dir = "D";
- }
- else if(this.yMovT < -1)
- {
- this.dir = "U";
- }
- }
- function evade()
- {
- this.f2 = "wander";
- this[this.axis + "MovT"] = 0;
- this.axis = random(10) <= 4 ? "y" : "x";
- this[this.axis + "MovT"] = random(2) <= 0 ? -1 * this.speed : this.speed;
- this.speedVar();
- this.getDirString();
- }
- function death()
- {
- _root.stats.destroyed = _root.stats.destroyed + 1;
- _root.stats.score += 1000;
- _root.powerUpB(this.x,this.y,80,"tripleLaserA",3);
- _root.createExploD([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_root.randRange(80,130),_root.randRange(75,100)]);
- var _loc3_ = 0;
- var _loc4_ = random(3);
- while(_loc3_ < _loc4_)
- {
- _root.createShrapnel([this.x + this.clip._width / 2,this.y + this.clip._height / 2,"batB","",false,true]);
- _loc3_ = _loc3_ + 1;
- }
- _root.audio.playLevel4("batX" + (random(2) + 1),_root.randRange(8,15));
- _root.removeChar("batD" + this.id);
- }
- function death2()
- {
- _root.removeChar("batD" + this.id);
- }
- function wander()
- {
- if(random(100) > 96 + _root.dif.wander)
- {
- this[this.axis + "MovT"] = 0;
- this.axis = this.axis != "x" ? "x" : "y";
- this[this.axis + "MovT"] = random(2) <= 0 ? -1 * this.speed : this.speed;
- this.getDirString();
- }
- }
- function main()
- {
- this[this.f2]();
- if(this.oldDir != this.dir)
- {
- this.clip.gotoAndStop("fly" + this.dir);
- }
- this.oldDir = this.dir;
- if(this.nudging)
- {
- this.xA *= 0.5;
- this.yA *= 0.5;
- this.nc = this.nc + 1;
- var _loc8_ = 255 - this.nc * 17;
- this.colorTrans.redOffset = _loc8_ / 2;
- this.trans.colorTransform = this.colorTrans;
- if(this.nc == 15)
- {
- this.xA = this.yA = 0;
- this.nudging = false;
- this.colorTrans.redOffset = this.colorR;
- this.trans.colorTransform = this.colorTrans;
- }
- }
- var _loc4_ = 0;
- var _loc7_ = _root.broShots.length;
- while(_loc4_ < _loc7_)
- {
- var _loc6_ = _root.broShots[_loc4_] + "Clip";
- if(this.clip.hitTest(_root[_loc6_]))
- {
- var _loc3_ = _root.broShots[_loc4_];
- var _loc5_ = this.life;
- this.life -= _root[_loc3_].power;
- if(this.life < 1)
- {
- this.f2 = "death";
- }
- else
- {
- this.nudge(_root[_loc3_].xMov,_root[_loc3_].yMov,10);
- _root.audio.playLevel4("batHit" + (random(2) + 1),_root.randRange(10,20));
- }
- _root[_root.char].fc = _root[_root.char].fireFreq - _root.rapidVar;
- _root[_loc3_].exploX = this.x + this.clip._width / 2;
- _root[_loc3_].exploY = this.y + this.clip._height / 2;
- _root[_loc3_].hit(_loc5_);
- break;
- }
- _loc4_ = _loc4_ + 1;
- }
- if(this.clip.hitTest(_root[_root.char + "Clip"]))
- {
- _root[_root.char].hit(this.xMov,this.yMov,100,this.power);
- this.f2 = "death";
- }
- if(this.x > 1050 || this.x < -50 || this.y < -50 || this.y > 650)
- {
- this.f2 = "death2";
- }
- if(this.xMovT < this.xMov)
- {
- this.xMov -= 1;
- }
- else if(this.xMovT > this.xMov)
- {
- this.xMov += 1;
- }
- else
- {
- this.xMov = this.xMovT;
- }
- if(this.yMovT < this.yMov)
- {
- this.yMov -= 1;
- }
- else if(this.yMovT > this.yMov)
- {
- this.yMov += 1;
- }
- else
- {
- this.yMov = this.yMovT;
- }
- this.x += this.xMov + this.xA;
- this.y += this.yMov + this.yA;
- this.clip._x = this.x;
- this.clip._y = this.y;
- }
- }
-